﻿using System.ComponentModel.DataAnnotations;
using PortalWeb.CMS.Core.Entity;

namespace PortalWeb.Models.Cms
{
    public class ProductViewModel : CommonModelViewModel
    {
        [Display(Name = "品牌")]
        public string Brand { get; set; }

        [Display(Name = "价格")]
        public decimal Price { get; set; }

        [Display(Name = "摘要")]
        [StringLength(255, ErrorMessage = "必填少于{0}个字")]
        public string Intro { get; set; }

        [Display(Name = "描述")]
        [Required(ErrorMessage = "必填")]
        [DataType(DataType.Html)]
        public string Content { get; set; }

        public ProductViewModel()
        {
        }

        public ProductViewModel(Product product)
        {
            this.Id = product.Id;
            this.CategoryId = product.CommonModel.CategoryId;
            this.Brand = product.Brand;
            this.Price = product.Price;
            this.Status = product.CommonModel.Status;
            this.Title = product.CommonModel.Title;
            this.ReleaseDate = product.CommonModel.ReleaseDate;
            this.Inputer = product.CommonModel.Inputer;
            this.Content = product.Content;
            this.Intro = product.Intro;
            this.DefaultPicUrl = product.CommonModel.DefaultPicUrl;
        }
    }
}